<include file="Public:header" />
<div class="page-member subpage">
    <div class="form-header">
        <div>
            <div class="line1">
                <div class="fl"><h3>年审详情 / {$nianshen.no}</h3></div>
                <div class="fr hidden">
                    <form class="search-form" method="post" action="">
                        <input name="field" value="{$context.field}" type="hidden" />
                        <input name="value" value="{$context.value}" type="hidden" />
                        <input name="page" value="{$context.page}" type="hidden" />
                        <input name="state" value="{$context.state}" type="hidden" />
                        <input name="order_field" value="{$context.order_field}" type="hidden" />
                        <input name="order_sort" value="{$context.order_sort}" type="hidden" />
                        <input name="offset" value="{$context.offset}" type="hidden" />
                        <input name="id" value="{$context.id}" type="hidden" />
                    </form>
                </div>
            </div>
            <div class="line2">
                <!-- 编辑按钮组 -->
                <if condition="$nianshen.state eq '审核中'">
                    <div class="fl form-btn-group btn-group-edit">
                        <if condition="$nianshen.lhsp eq 0">
                            <button disabled=disabled onclick="action_fenpeify();" class="btn-save btn-disable">审 批</button>
                        <else />
                            <in name="$x|default='02-02-04'" value="$rightsCode">
                                <button onclick="action_shenpi();" class="btn-save btn-highlight">审 批</button>
                                <else />
                                <button disabled="disabled" class="btn-save btn-disable">审 批</button>
                            </in>
                        </if>
                        <span>或</span>
                        <a onclick="action_edit();" class="linkBtn btn-abort" href="javascript:void(0);">编辑</a>
                    </div>
                </if>
                <!-- 保存按钮组 -->
                <div class="fl form-btn-group btn-group-save hidden">
                    <in name="$x|default='02-02-04'" value="$rightsCode">
                        <button onclick="action_save();" class="btn-save btn-highlight">保 存</button>
                        <else />
                        <button disabled="disabled" class="btn-save btn-disable">保 存</button>
                    </in>
                    <span>或</span>
                    <a class="linkBtn btn-abort" onclick="action_abort();" href="javascript:void(0);">放弃</a>
                </div>
                <div class="fl form-btn-more">
                    <button class="btn-normal btn-more">
                        更多操作<i class="drop-down"></i>
                    </button>
                    <ul class="more-action hidden">
                        <in name="$x|default='02-02-04'" value="$rightsCode">
                            <li><a onclick="action_del2();" href="javascript:void(0);">删 除</a></li>
                            <li><a onclick="action_blacklist();" href="javascript:void(0);">移入黑名单</a></li>
                        </in>
                    </ul>
                </div>
                <div class="fr form-search-count">
                    <span class="index">{$context.index}/{$page.total}</span>
                    <button onclick="ItemJump({$page.prev.id}, {$page.prev.offset});" class="btn-normal">上一条</button>
                    <button onclick="ItemJump({$page.next.id}, {$page.next.offset});" class="btn-normal">下一条</button>
                </div>
            </div>
        </div>
    </div>
    <div class="form-box2" style="margin-bottom:5px;">
        <div style="border-bottom:0;padding-bottom:0;">
            <form id="nianshenForm" method="post" action="">
                <!--表单相关原始信息存储-->
                <input type="hidden" name="old_no" value="{$nianshen.no}" />
                <input type="hidden" name="old_name" value="{$nianshen.name}" />
                <input type="hidden" name="old_seq" value="{$nianshen.seq}" />
                <input type="hidden" name="old_batch_id" value="{$nianshen.batch_id}" />
                <input type="hidden" name="old_idno" value="{$nianshen.idno}" />
                <input type="hidden" name="old_phone" value="{$nianshen.phone}" />
                <input type="hidden" name="old_house_no" value="{$nianshen.house_no}" />
                <input type="hidden" name="old_state" value="{$nianshen.state}" />
                <input type="hidden" name="old_remarks" value="{$nianshen.remarks}" />
                <input type="hidden" name="old_contact_no" value="{$nianshen.contact_no}" />
                <table class="form">
                    <tr>
                        <th width="15%">年审编号<span class="hint">*</span></th>
                        <td width="35%" field="batch_id">{$nianshen.no}</td>
                        <th width="15%">年份<span class="hint">*</span></th>
                        <td field="seq">{$nianshen.year}</td>
                    </tr>
                    <tr>
                        <th>姓名<span class="hint">*</span></th>
                        <td field="name">{$nianshen.name}</td>
                        <th>身份证<span class="hint">*</span></th>
                        <td field="idno">{$nianshen.idno}</td>
                    </tr>
                    <tr>
                        <th>联系电话<span class="hint">*</span></th>
                        <td field="phone">{$nianshen.phone}</td>
                        <th>房源地址<span class="hint">*</span></th>
                        <td field="house_addr">{$nianshen.house_addr}</td>
                    </tr>
                    <tr>
                        <th>申请编号<span class="hint">*</span></th>
                        <td field="no">{$nianshen.yw_no}</td>
                        <th>合同编号</th>
                        <td field="contact_no">{$nianshen.contact_no}</td>
                    </tr>
                    <tr>
                        <th>状态<span class="hint">*</span></th>
                        <td field="state">{$nianshen.state}</td>
                        <th>备注</th>
                        <td field="remarks">{$nianshen.remarks}</td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <div class="sub-listview" style="height:320px;">
        <ul class="ui-tabs">
            <li class="selected" target="tabs-lhsp">联合审批</li>
        </ul>
        <div class="tabs-item tabs-lhsp" style="height:290px;overflow-y:auto;">
            <table class="list" style="margin-top:10px;">
                <thead>
                <tr>
                    <th width="150">审批单位</th>
                    <th>审批意见</th>
                    <th width="50">审批人</th>
                    <th width="70">审批时间</th>
                </tr>
                </thead>
                <tbody>
                <volist name="lhsp" id="vo">
                    <tr <if condition="$vo.spzt eq 未通过">class="warning"</if>>
                    <td>{$vo.spdw}</td>
                    <td>{$vo.spyj|default='未审批'}</td>
                    <td>{$vo.spr}</td>
                    <td>
                        <neq name="vo.sptime" value="">
                            {$vo.sptime|date="Y/m/d",###}
                        </neq>
                    </td>
                    </tr>
                </volist>
                </tbody>
            </table>
        </div>
    </div>
</div>
<div class="dialog dialog-shenpi hidden">
    <div class="box">
        <div class="title">
            <h4 class="fl">年审审批对话框</h4>
            <span class="fr"><a href="#" onclick="closeDialog();">关闭</a></span>
        </div>
        <table class="form-tab">
            <tr>
                <th width="100">审批状态：</th>
                <td>
                    <input name="spzt" checked="checked" value="审核通过" type="checkbox" /><label>同意</label>
                    <input name="spzt" value="审核失败" type="checkbox" /><label>拒绝</label>
                </td>
            </tr>
            <tr>
                <th>审批意见：</th>
                <td>
                    <textarea name="spyj"></textarea>
                    <select name="opinion" target="spyj" style="margin:5px 0;">
                        <option value="">--选择常用审批意见--</option>
                        <volist name="opinion" id="vo">
                            <option value="{$vo.name}">{$vo.name}</option>
                        </volist>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;line-height:40px;">
                    <button class="btn btn-highlight" onclick="action_submit();">提交</button>
                    <span>或</span>
                    <a href="#" onclick="closeDialog();" class="linkBtn">放弃</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<link type="text/css" href="__JS__/autocomplete2/src/jquery.autocomplete.min.css" rel="stylesheet">
<script src="__JS__/autocomplete2/src/jquery.autocomplete.js" type="text/javascript"></script>
<script>
    function action_submit() {
        var spzt = null;
        $("input[name=spzt]").each(function () {
            if($(this).prop("checked")){
                spzt = $(this).val();
            }
        });
        if(!spzt){
            alert("请填写审批状态");
            return false;
        }
        var spyj = $("textarea[name=spyj]").val();
        if(!spyj && spzt=="拒绝"){
            alert("请填写审批意见");
            return false;
        }

        var id = $("input[name=id]").val();
        $.ajax({
            url:"/admin/nianshen/ajax_nianshen",
            data: {id:id, spzt:spzt, spyj:spyj}, type:"POST", dataType:"JSON",
            success: function(data){
                if(data.status){
                    alert("审批成功，系统自动跳转到下一条记录");
                    ItemJump({$page.next.id}, {$context.offset});//跳转到下一条记录；offset不变
                }else{
                    console.log(data.info);
                    alert(data.info);
                }
            }
        });
    }

    /**
     * 打开年审审批对话框
     */
    function action_shenpi() {
        $(".dialog-shenpi").show();
    }

    /**
     * 关闭对话框
     */
    function closeDialog() {
        $(".dialog").hide();
    }
</script>
<script>
    /**
     * 全局变量 fields
     */
    var fields = new Array("remarks");
</script>
<script src="__JS__/nianshen.js" type="text/javascript" ></script>
<include file="Public:footer" />
